﻿using IterationLife.Datas;
using IterationLife.Domains.Sports.Models;
using IterationLife.Domains.Sports.Queries;
using IterationLife.Domains.Sports.Repositories;
using IterationLife.Football.MTSports.Contracts.Sports;
using IterationLife.Football.MTSports.Dtos.Sports;
using Util.Applications;
using Util.Datas.Queries;

namespace IterationLife.Football.MTSports.Impl.Sports
{
    /// <summary>
    /// 体育比赛分组服务
    /// </summary>
    public class SportEventGroupService : ApplicationServiceBase<SportEventGroup, SportEventGroupDto, SportEventGroupQuery>, ISportEventGroupService
    {
        /// <summary>
        /// 初始化体育比赛分组服务
        /// </summary>
        /// <param name="unitOfWork">工作单元</param>
        /// <param name="sportEventGroupRepository">体育比赛分组仓储</param>
        public SportEventGroupService(IApplicationUnitOfWork unitOfWork, ISportEventGroupRepository sportEventGroupRepository)
            : base(unitOfWork, sportEventGroupRepository)
        {
            SportEventGroupRepository = sportEventGroupRepository;
        }

        /// <summary>
        /// 体育比赛分组仓储
        /// </summary>
        protected ISportEventGroupRepository SportEventGroupRepository { get; set; }

        /// <summary>
        /// 转换为数据传输对象
        /// </summary>
        /// <param name="entity">实体</param>
        protected override SportEventGroupDto ToDto(SportEventGroup entity)
        {
            return entity.ToDto();
        }

        /// <summary>
        /// 转换为实体
        /// </summary>
        /// <param name="dto">数据传输对象</param>
        protected override SportEventGroup ToEntity(SportEventGroupDto dto)
        {
            return dto.ToEntity();
        }

        /// <summary>
        /// 创建查询对象
        /// </summary>
        /// <param name="param">体育比赛分组查询实体</param>
        protected override IQueryBase<SportEventGroup> CreateQuery(SportEventGroupQuery param)
        {
            return new Query<SportEventGroup>(param);
        }
    }
}